const { querySql , updateSql, insertSql } = require('../db')


function getMenuList(query) {
  const { menuState , menuName } = query
  return querySql(`select * from menu_list where menuState = ${menuState} AND menuName like '%${menuName || ''}%'`)
}

function editMenu(query){
  query.updateTime = new Date()
  return updateSql( query , 'menu_list' , `where id = ${query.id}` )
}

function createMenu(query,cardId){
  query.createTime = new Date() 
  query.createId = cardId
  return insertSql( query , 'menu_list' )
}

function deleteMenu(query){
  return updateSql( { menuState: 2 } , 'menu_list' , `where id = ${query.id}` )
}

module.exports = {
  getMenuList,
  editMenu,
  createMenu,
  deleteMenu
} 